package two.chapter_1.c1_3;

import edu.princeton.cs.algs4.StdOut;


public class Ex1_3_5 {

    public static void main(String [] args){

        StdOut.println(binary(50));

    }

    /**
     * 除二取余法
     * @param N
     * @return
     */
    private static String binary(int N){
        Stack<Integer> stack=new LinkStack<>();
        while (N>0){
            stack.push(N%2);
            N=N/2;
        }
        StringBuilder sBuilder=new StringBuilder();
        for (int d:stack){
            sBuilder.append(d);
        }
        return sBuilder.toString();
    }
}
